<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script>

        function transferValue(value){
            var isNaN = isNaN(value);
            if(isNaN == false){
                var newStr = value.toString();
                if(newStr.split('.')[1].length >2){
                    alert("只支持两位小数的转换")
                    return
                }
            }else{
                alert("不是一个数字，不能进行转换")
                return
            }
            var capitalNum = "零壹贰叁肆伍陆柒捌玖",
                moneyUnit = "万仟百拾亿仟百拾万仟百拾元角分",
                moneyValueString = (value*100).toString(),
                moneyValueLength = moneyValueString.length,
                newMoneyUnit = moneyUnit.substr(moneyUnit.length-moneyValueLength),
                count = 0,//记录传入金额中0的个数
                million = 0, //记录万的个数
                capital = ""; //记录大写金额
            for(var i=1;i< moneyValueLength +1;i++){
                var lowercasePer = moneyValueString.substr(i-1,1),//每一位小写字符（数字）
                    upperCasePer = capitalNum.substr(lowercasePer,1),//每一位小写数字对应的大写汉字
                    unit = newMoneyUnit.substr(i-1,1);
                if(upperCasePer == "零"){
                    upperCasePer = ""
                    if(unit == "亿"){
                    }else if(unit == "万"){
                        upperCasePer = "";
                        million++;
                    }else if(unit == "元"){

                    }else{
                        unit = "";
                    }
                    count=count+1;
                }else{
                    if(count-million>0){
                        if(unit!="角"){
                            upperCasePer = "零"+upperCasePer;
                        }
                    }
                    count= 0;
                }
                capital = capital + upperCasePer + unit
            }
            if(newstring.length!=1){
                if(newstring.substr(newstring.length-2)=="00"){
                    capital = capital + "整";
                }else{
                    capital  = capital ;
                }
            }
            return capital ;
        }
        function f() {
            var elementById = document.getElementById('a');
            transferValue(parseInt(elementById.value))
        }
    </script>
</head>
<body>
<input type="text" id="a" value="">
<input type="button"  value="点击" onclick="f()">
</body>
</html>